import Vue from 'vue'
import moment from 'moment'

Vue.filter('genderFormat', (value) => {
  switch (value) {
    case 1:
      return '男'
    case 0:
      return '女'
    default:
      return '未知'
  }
})

Vue.filter('date', (value, format) => {
  return moment(value).format(format)
})

Vue.filter('subStr', (value, number) => {
  if(typeof(value) === 'string' && value.length !== 0) {
    if(value.length <= number) {
      return value
    } else {
      return value.substr(0, number) + '...'
    }
  } else {
    return value
  }
  return moment(value).format(format)
})
